package Framework 
{
	import flash.display.Sprite;
	import flash.utils.ByteArray;
	/**
	 * ...
	 * @author Menno
	 */
	public class GameHelper 
	{
		
		public function GameHelper() 
		{
			
		}
		
		public static function getDistance(a:Sprite, b:Sprite):Number
		{
			var dy:Number;
			var dx:Number;
			
			dx = b.x - a.x;
			dy = b.y - a.y;

			return Math.sqrt(dx * dx + dy * dy);			
		}
		
		/**
		 * Code gekopieerd van http://www.flexer.info/2007/11/07/compare-two-objects/
		 */
		public static function compareObject(obj1:Object,obj2:Object):Boolean
		{
			var buffer1:ByteArray = new ByteArray();
			buffer1.writeObject(obj1);
			var buffer2:ByteArray = new ByteArray();
			buffer2.writeObject(obj2);
 
			// compare the lengths
			var size:uint = buffer1.length;
			if (buffer1.length == buffer2.length) 
			{
				buffer1.position = 0;
				buffer2.position = 0;
		 
				// then the bits
				while (buffer1.position < size) 
				{
					var v1:int = buffer1.readByte();
					if (v1 != buffer2.readByte())
					{
						return false;
					}
				}    
				return true;                        
			}
			return false;
		}
	}
}